package com.tyut.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tyut.common.annotation.Log;
import com.tyut.common.core.controller.BaseController;
import com.tyut.common.core.domain.AjaxResult;
import com.tyut.common.enums.BusinessType;
import com.tyut.system.domain.TyutPaper;
import com.tyut.system.service.ITyutPaperService;
import com.tyut.common.utils.poi.ExcelUtil;
import com.tyut.common.core.page.TableDataInfo;

/**
 * 论文管理Controller
 * 
 * @author tyut
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/paper/tyutpaper")
public class TyutPaperController extends BaseController
{
    @Autowired
    private ITyutPaperService tyutPaperService;

    /**
     * 查询论文管理列表
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:list')")
    @GetMapping("/list")
    public TableDataInfo list(TyutPaper tyutPaper)
    {
        startPage();
        List<TyutPaper> list = tyutPaperService.selectTyutPaperList(tyutPaper);
        return getDataTable(list);
    }

    /**
     * 导出论文管理列表
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:export')")
    @Log(title = "论文管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TyutPaper tyutPaper)
    {
        List<TyutPaper> list = tyutPaperService.selectTyutPaperList(tyutPaper);
        ExcelUtil<TyutPaper> util = new ExcelUtil<TyutPaper>(TyutPaper.class);
        util.exportExcel(response, list, "论文管理数据");
    }

    /**
     * 获取论文管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tyutPaperService.selectTyutPaperById(id));
    }

    /**
     * 新增论文管理
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:add')")
    @Log(title = "论文管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TyutPaper tyutPaper)
    {
        return toAjax(tyutPaperService.insertTyutPaper(tyutPaper));
    }

    /**
     * 修改论文管理
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:edit')")
    @Log(title = "论文管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TyutPaper tyutPaper)
    {
        return toAjax(tyutPaperService.updateTyutPaper(tyutPaper));
    }

    /**
     * 删除论文管理
     */
    @PreAuthorize("@ss.hasPermi('paper:tyutpaper:remove')")
    @Log(title = "论文管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tyutPaperService.deleteTyutPaperByIds(ids));
    }
}
